package edu.put.sk.nrpp.ospf.packet;

import edu.put.sk.nrpp.*;
/**
 * 
 <pre>
        0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0  0   |   Version #   |       1       |         Packet length         |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1  32  |                          Router ID                            |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2  64  |                           Area ID                             |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3  96  |           Checksum            |             AuType            |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4  128 |                       Authentication                          |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5  160 |                       Authentication                          |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
6  192 |                        Network Mask                           |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
7  224 |         HelloInterval         |    Options    |    Rtr Pri    |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
8  256 |                     RouterDeadInterval                        |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
9  288 |                      Designated Router                        |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
10 320 |                   Backup Designated Router                    |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
11 352 |                          Neighbor                             |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                              ...                              |
</pre>
 * @author kevin
 *
 */

final public class OSPFPacketVersion2Type1 extends OSPFPacket{
	
	
	
	public OSPFPacketVersion2Type1(Bit[] data){
		super(data);
	}
	
	/**
	 * Network mask
        The network mask associated with this interface.  For example,
        if the interface is to a class B network whose third byte is
        used for subnetting, the network mask is 0xffffff00.
	 * @return mask int
	 */
	public int getNetworkMask(){
		return Bit.toInt(Bit.cut(data, 192, 223));
	}
	
	/**
	 * HelloInterval
        The number of seconds between this router's Hello packets.
	 * @return int Hello Interval
	 */
	public int getHelloInterval(){
		return Bit.toInt(Bit.cut(data, 224, 239));
	}
	
	/**
	 *  Options
        The optional capabilities supported by the router, as documented
        in Section A.2.
	 * @return int options
	 */
	public int getOptions(){
		return Bit.toInt(Bit.cut(data, 240, 247));
	}
	
	/**
	 * Rtr Pri
        This router's Router Priority.  Used in (Backup) Designated
        Router election.  If set to 0, the router will be ineligible to
        become (Backup) Designated Router.
	 * @return int Router Priority
	 */
	public int getRtrPri(){
		return Bit.toInt(Bit.cut(data, 248, 255));
	}
	
	/**
	 * RouterDeadInterval
        The number of seconds before declaring a silent router down.
	 * @return
	 */
	public int getRouterDeadInterval(){
		return Bit.toInt(Bit.cut(data, 256, 287));
	}
	
	/**
	 *  Designated Router
        The identity of the Designated Router for this network, in the
        view of the sending router.  The Designated Router is identified
        here by its IP interface address on the network.  Set to 0.0.0.0
        if there is no Designated Router.
	 * @return
	 */
	public int getDesignatedRouter(){
		return Bit.toInt(Bit.cut(data, 288, 319));
	}
	
	
	/**
	 * Backup Designated Router
        The identity of the Backup Designated Router for this network,
        in the view of the sending router.  The Backup Designated Router
        is identified here by its IP interface address on the network.
        Set to 0.0.0.0 if there is no Backup Designated Router.
	 * @return
	 */
	public int getBackupDesignatedRouter(){
		return Bit.toInt(Bit.cut(data, 320, 351));
	}
	
	/**
	 * Neighbor
        The Router IDs of each router from whom valid Hello packets have
        been seen recently on the network.  Recently means in the last
        RouterDeadInterval seconds.
	 * @return
	 */
	public int getNeighbor(){
		return Bit.toInt(Bit.cut(data, 352, 383));
	}
	
}